package com.controls
{
	import com.models.WorkFlow;
	
	import flash.events.MouseEvent;
	
	import mx.controls.Button;
	import com.data.ToolIcon;

	/**
	 * Klasse für einen ToolButton
	 */
	public class ToolButton extends Button
	{
		
		private var _behaviour:IButtonBehaviour;
		private var _model:WorkFlow;
		
		/**
		 * Konstruktor
		 * 
		 */
		public function ToolButton(pBehaviour:IButtonBehaviour, pModel:WorkFlow)
		{
			super();
			_behaviour = pBehaviour;
			_model = pModel;
			pBehaviour.reference = this;
		}
		
		
		//public------------------------------------------------
		
		public function getModel():WorkFlow
		{
			return _model;
		}
		
		//private-----------------------------------------------
		
		private function addListeners():void
		{
			addEventListener(MouseEvent.CLICK, _behaviour.mouseClickHandler);
		}
		
		
		
		
		//protected---------------------------------------------
		
		protected override function createChildren():void
		{
			super.createChildren();
			setStyle("icon", _behaviour.icon);
			addListeners();
			this.label = _behaviour.label;
		}
		
		//eventhandler------------------------------------------
		
	}
}